import platform = require('../../../../../platform/common/baseCommon');
import appClient = require('../../../../../platform/client/appClient');
import platformControls = require('../../../../../platform/client/controls');
import echartControls = require('../../../../../platform/client/echartControls')
import report = require('../../../../../platform/client/report');


let dataService1 = new appClient.asyncFactory(platform.IDataService, "remoteCall", "example");

let fetcher_country = new report.dataServiceFetcher();
fetcher_country.name = "fetcher_country";
fetcher_country.command = "cmd_country";
fetcher_country.dataService = dataService1;

let dataSource_country = new platform.dataQuerySource();
dataSource_country.name = "data_country";
dataSource_country.fetcher = fetcher_country;

/** 数据显示器:参数输入 */
let paramReport = new report.parameterControl();
paramReport.name = "report_parameters";
paramReport.fields = [];
paramReport.caption = "查询条件";
paramReport.dataSourceNames = [dataSource_country.name];

let displayer_country = new report.echartsDataDisplayer();
displayer_country.name = "report_country";
displayer_country.caption = "国家人口与土地面积分析";
displayer_country.style("height", 350);
let view_country = new platform.dataView();
view_country.dataSourceName = dataSource_country.name;
displayer_country.dataViews = {};
displayer_country.dataViews["view_country"] = view_country;
//折线图
let axisSerie = new echartControls.axisSerie();
//饼图
let pieSerie = new echartControls.pieSerie();


let field_name = new platform.dataField();
field_name.name = "Name";
field_name.caption = "国家名称";
let field_area = new platform.dataField();
field_area.name = "SurfaceArea";
field_area.caption = "土地面积";
let field_population = new platform.dataField();
field_population.name = "Population";
field_population.caption = "人口";

//折线图配置
axisSerie.xAxis = {
    type: "category",
    axises: [{
        position: "buttom"
    }]
};
axisSerie.yAxis = {
    type: "value",
    axises: [{
        caption: "人口",
        position: "left"
    }, {
        caption: "土地面积(km²)",
        position: "right"
    }]
};
axisSerie.categoryFields = [{
    field: field_name,
    index: 0
}];
axisSerie.valueFields = [{
    type: "line",
    field: field_population,
    xAxisIndex: 0,
    yAxisIndex: 0
}, {
    type: "bar",
    field: field_area,
    xAxisIndex: 0,
    yAxisIndex: 1
}];

//饼图配置
pieSerie.fieldTypeName = '姓名';
pieSerie.pieNumber = 3;
pieSerie.fieldData = [];
let field_China = new platform.dataField();
field_China.name = "语文";
field_China.caption = "语文";
let field_math = new platform.dataField();
field_math.name = "数学";
field_math.caption = "数学";
let field_py = new platform.dataField();
field_py.name = "物理";
field_py.caption = "物理";
pieSerie.fieldData = [field_China, field_math, field_py];




displayer_country.echartObject = axisSerie;
//displayer_country.echartObject = pieSerie;
/**
 * 国家人口与土地面积分析
 * @description 国家人口与土地面积分析
 */
export let defaultObject = new report.smartReport();
defaultObject.caption = "国家人口与土地面积分析";
defaultObject.dataSources = {};
defaultObject.dataSources[dataSource_country.name] = dataSource_country;
defaultObject.layoutPanel = new platformControls.layoutPanel("project/test/config/client/smartReportApp/layout/layout.html");
defaultObject.modules = {};
defaultObject.modules[paramReport.name] = paramReport;
defaultObject.modules[displayer_country.name] = displayer_country;
defaultObject.autoQuery = false;
defaultObject.requestParameterKeys = ["name"];